<?php

require_once 'model/usuarios.php';

abstract class ActUsuarios extends mUsuarios {
	
	protected $sqlInsert = "insert into usuarios (usuario,senha) values ('%s','%s')";
	protected $sqlDelete = "delete from usuarios where usuario = '%s'";
	protected $sqlUpdate = "update usuarios set senha='%s' where usuario='%s'";
	protected $sqlSelect = "select * from usuarios %s %s";
	

	public function load(){
		$rs = $this->select(sprintf("where usuario = '%s'",$this->getUsuario()));
		$this->setUsuario($rs[0]['usuario']);
		$this->setCriptedSenha($rs[0]['senha']);		
		return $this;
	}

	
	
	public function insert(){
		$sql = sprintf($this->sqlInsert,
					   $this->getUsuario(),
					   $this->getSenha()
					  );
		return $this->RunQuery($sql);
	}
	
	public function delete (){
		$sql = sprintf($this->sqlDelete,
					   $this->getUsuario()
					  );
		return $this->RunQuery($sql);
	}
	
	public function update(){
		$sql = sprintf($this->sqlUpdate,
					   $this->getSenha()
					  );
		return $this->RunQuery($sql);
	}
	
	public function select($where = '', $oder=''){
		$sql = sprintf($this->sqlSelect,
						$where,
						$oder
					   );
		return $this->RunSelect($sql);			   
	}
}
?>